100 REM **********************************************************************
110 REM
120 REM		FILENAME	VIEW.BAS
130 REM		WRITTEN BY	GARY PEEK
140 REM		LAST UPDATE	08/05/92
150 REM		DESCRIPTION	VIEW FILES IN CURRENT DIRECTORY AT RIGHT.
160 REM				SELECT SORTED FILES IN A COLUMN AT LEFT.
170 REM				(SIMILAR TO LOTUS MAGELLAN FILE VIEW)
180 REM
190 REM **********************************************************************
200 KEY OFF
210 FOR A=1 TO 10:KEY A,"":NEXT A
220 GOTO 370
230 REM -----
300 SHEL$="DIR *.* | SORT > FILES.TMP":SHELL SHEL$:GOTO 320
310 SHEL$="DIR *.* | SORT /+10 > FILES.TMP":SHELL SHEL$:GOTO 320
320 ON ERROR GOTO 420
330 OPEN "FILES.TMP" FOR INPUT AS 1
340 IF LOF(1)=0 THEN CLOSE #1:GOTO 360
350 GOTO 450
360 PRINT:PRINT "SORT utility not in DOS path"
370 SHEL$="DIR *.* > FILES.TMP":SHELL SHEL$
380 ON ERROR GOTO 420
390 OPEN "FILES.TMP" FOR INPUT AS 1
400 IF LOF(1)=0 THEN CLOSE #1:COLOR 7,0:END
410 GOTO 450
420 RESUME 430
430 ON ERROR GOTO 0:COLOR 7,0:END
440 REM -----
450 ON ERROR GOTO 0
460 DIM FILENAME$(1000):NUMFILES=0
470 IF EOF(1) THEN 600
480 INPUT #1,FILE$
490 IF LEFT$(FILE$,12)="FILES    TMP" THEN 470
500 IF MID$(FILE$,9,1)<>" " THEN 470
510 IF LEFT$(FILE$,1)="." THEN 470
520 IF VAL(MID$(FILE$,14,8))=0 THEN 470
530 NUMFILES=NUMFILES+1
540 FILENAME$(NUMFILES)=LEFT$(FILE$,12)
550 IF NUMFILES>1000 THEN 600
560 GOTO 470
570 REM -----
600 CLOSE 1:KILL "FILES.TMP"
610 IF NUMFILES=0 THEN COLOR 7,0:END
620 ON ERROR GOTO 0
630 REM -----
640 CURROW=1:OLDROW=CURROW
650 MAXROW=19:IF NUMFILES<19 THEN MAXROW=NUMFILES
660 SRTROW=1
670 REM ----- LEFT BOXES
700 CLS
710 TP=196:BT=196:MS=179:UL=218:LL=192:UR=191:LR=217:ML=195:MR=180
720 LOCATE 1,1:PRINT CHR$(UL)+STRING$(14,CHR$(TP))+CHR$(UR);
730 LOCATE 2,1:PRINT CHR$(MS)+STRING$(14,CHR$(32))+CHR$(MS);
740 LOCATE 3,1:PRINT CHR$(ML)+STRING$(14,CHR$(TP))+CHR$(MR);
750 DCOL=1:FOR ROW=4 TO 22:LOCATE ROW,DCOL:PRINT CHR$(MS);:NEXT
760 DCOL=16:FOR ROW=4 TO 22:LOCATE ROW,DCOL:PRINT CHR$(MS);:NEXT
770 LOCATE 23,1:PRINT CHR$(ML)+STRING$(14,CHR$(TP))+CHR$(MR);
780 LOCATE 24,1:PRINT CHR$(MS)+STRING$(14,CHR$(32))+CHR$(MS);
790 LOCATE 25,1:PRINT CHR$(LL)+STRING$(14,CHR$(BT))+CHR$(LR);
800 REM ----- DISPLAY MESSAGES
810 LOCATE 2,2:PRINT "F1,F2,F3=sort";
820 LOCATE 24,2:PRINT " "+CHR$(26)+" run BROWSE";
830 REM ----- RIGHT BOX
840 LOCATE 1,18:PRINT CHR$(UL);:LOCATE 1,80:PRINT CHR$(UR);
850 LOCATE 25,18:PRINT CHR$(LL);:LOCATE 25,80:PRINT CHR$(LR);
860 FOR DCOL=19 TO 79:LOCATE 1,DCOL:PRINT CHR$(TP);:NEXT DCOL
870 FOR DCOL=19 TO 79:LOCATE 25,DCOL:PRINT CHR$(BT);:NEXT DCOL
880 FOR DROW=2 TO 24:LOCATE DROW,18:PRINT CHR$(MS);:NEXT DROW
890 FOR DROW=2 TO 24:LOCATE DROW,80:PRINT CHR$(MS);:NEXT DROW
900 LOCATE 23,18:PRINT CHR$(ML);:LOCATE 23,80:PRINT CHR$(MR);
910 FOR DCOL=19 TO 79:LOCATE 23,DCOL:PRINT CHR$(TP);:NEXT DCOL
920 LOCATE 24,20:PRINT "VIEW - file viewing utility            written by GARY PEEK";
930 REM ----- DISPLAY FILE NAMES
940 COLOR 15,0
950 FOR DISPLAYROW=1 TO MAXROW
960   LOCATE DISPLAYROW+3,3
970   PRINT FILENAME$(DISPLAYROW-1+SRTROW);
980 NEXT DISPLAYROW
990 REM ----- MOVE THROUGH FILE NAMES
1000 LOCATE CURROW+3,3,0
1010 COLOR 0,7
1020 PRINT FILENAME$(CURROW-1+SRTROW);
1030 COLOR 15,0
1040 LOCATE CURROW+3,3
1050 GOTO 2390
1060 REM ----- LOOP BACK HERE
2000 IN$=INKEY$:IF IN$="" THEN 2000
2010 IF IN$=CHR$(27) THEN ERASE FILENAME$:COLOR 7,0:CLS:END
2020 IF IN$=CHR$(0)+CHR$(77) THEN CLS:ERASE FILENAME$:SHELL "BROWSE "+FILE$:GOTO 370
2100 IF IN$=CHR$(0)+CHR$(72) THEN 2190:REM UP
2110 IF IN$=CHR$(0)+CHR$(80) THEN 2220:REM DOWN
2120 IF IN$=CHR$(0)+CHR$(73) THEN 2250:REM PAGE UP
2130 IF IN$=CHR$(0)+CHR$(81) THEN 2280:REM PAGE DOWN
2140 IF IN$=CHR$(0)+CHR$(59) THEN CLS:ERASE FILENAME$:GOTO 370
2150 IF IN$=CHR$(0)+CHR$(60) THEN CLS:ERASE FILENAME$:GOTO 300
2160 IF IN$=CHR$(0)+CHR$(61) THEN CLS:ERASE FILENAME$:GOTO 310
2170 GOTO 2000
2180 REM -----
2190 IF CURROW>1 THEN OLDROW=CURROW:CURROW=CURROW-1:GOTO 2320
2200 IF SRTROW>1 THEN SRTROW=SRTROW-1:GOTO 940
2210 GOTO 2000
2220 IF CURROW<MAXROW THEN OLDROW=CURROW:CURROW=CURROW+1:GOTO 2320
2230 IF NUMFILES>MAXROW AND SRTROW<NUMFILES-19 THEN SRTROW=SRTROW+1:GOTO 940
2240 GOTO 2000
2250 IF SRTROW>18 THEN SRTROW=SRTROW-18:GOTO 940
2260 IF SRTROW<>1 THEN SRTROW=1:GOTO 940
2270 GOTO 2000
2280 IF SRTROW+18<NUMFILES-19 THEN SRTROW=SRTROW+18:GOTO 940
2290 IF SRTROW<NUMFILES-19 THEN SRTROW=NUMFILES-19:GOTO 940
2300 GOTO 2000
2310 REM ----- HIGHLIGHT NEW FILE
2320 LOCATE OLDROW+3,3
2330 COLOR 15,0
2340 PRINT FILENAME$(OLDROW-1+SRTROW);
2350 LOCATE CURROW+3,3
2360 COLOR 0,7
2370 PRINT FILENAME$(CURROW-1+SRTROW);
2380 REM ----- FILE WAS SELECTED
2390 FILE$=FILENAME$(CURROW-1+SRTROW)
2400 MID$(FILE$,INSTR(FILE$," "),1)="."
2410 A=INSTR(FILE$," ")
2420 IF A<>0 THEN FILE$=LEFT$(FILE$,A-1)+RIGHT$(FILE$,LEN(FILE$)-A):GOTO 2410
2430 REM ----- DISPLAY FILE SELECTED
2500 OPEN FILE$ FOR INPUT AS 1
2510 COLOR 7,0
2520 FOR DROW=2 TO 22
2530   IN$=INKEY$:IF IN$<>"" THEN CLOSE #1:GOTO 2010
2540   LOCATE DROW,20:PRINT SPACE$(60);
2550 NEXT DROW
2560 FOR DROW=2 TO 22
2570   IN$=INKEY$:IF IN$<>"" THEN CLOSE #1:GOTO 2010
2580   IF EOF(1) THEN 2690
2590   LINE INPUT #1,L$
2600   FOR CHAR=1 TO LEN(L$)
2610   IN$=INKEY$:IF IN$<>"" THEN CLOSE #1:GOTO 2010
2620     A=ASC(MID$(L$,CHAR,1))
2630     IF A=9 THEN MID$(L$,CHAR,1)=CHR$(254):GOTO 2650
2640     IF A<32 OR A>126 THEN MID$(L$,CHAR,1)="."
2650   NEXT CHAR
2660   IF LEN(L$)>59 THEN L$=LEFT$(L$,59)
2670   LOCATE DROW,20:PRINT L$;
2680 NEXT DROW
2690 CLOSE #1
2700 REM LOCATE 25,1,0
2710 REM -----
2720 GOTO 2000
